package cn.huiyunche.admin.tms.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.huiyunche.base.service.interfaces.TmsQueueService;
import cn.huiyunche.base.service.model.DUserExt;
import cn.huiyunche.base.service.model.DWaybill;
import cn.huiyunche.base.service.vo.Result;

/**
 * 人送 队列管理
 * 
 * @author hdy [Tuffy]
 *
 */
@Controller
@RequestMapping("/tmsqueue")
public class TmsQueueController {

	@Autowired
	private TmsQueueService tmsQueueService = null;

	/**
	 * 订单重置顶排队
	 * 
	 * @param orderCodes
	 *            订单编号
	 * @return 结果集
	 * @throws Exception 
	 */
	@RequestMapping(value = "/top", method = RequestMethod.POST)
	@ResponseBody
	public Result<String> topQueueOrder(String orderCodes) throws Exception {
		return this.tmsQueueService.resetQueueOrder(orderCodes);
	}

	/**
	 * 获取队列订单信息
	 * 
	 * @return 结果集
	 * @throws Exception 
	 */
	@RequestMapping(value = "/list", method = RequestMethod.GET)
	@ResponseBody
	public Result<List<DWaybill>> queueOrderList() throws Exception {
		return this.tmsQueueService.queueOrderList();
	}

	/**
	 * 删除队列订单信息
	 * 
	 * @param orderCodes
	 *            订单编号
	 * @return 结果集
	 * @throws Exception 
	 */
	@RequestMapping(value = "/remove", method = RequestMethod.POST)
	@ResponseBody
	public Result<String> removeQueueOrder(String orderCodes) throws Exception {
		return this.tmsQueueService.removeQueueOrder(orderCodes);
	}

	/**
	 * 获取队列司机信息
	 * 
	 * @return 结果集
	 * @throws Exception 
	 */
	@RequestMapping(value = "/listdriver", method = RequestMethod.GET)
	@ResponseBody
	public Result<List<DUserExt>> queueDriverList() throws Exception {
		return this.tmsQueueService.queueDriverList();
	}

	/**
	 * 删除队列司机信息
	 * 
	 * @param orderCodes
	 *            订单编号
	 * @return 结果集
	 * @throws Exception 
	 */
	@RequestMapping(value = "/removedriver", method = RequestMethod.POST)
	@ResponseBody
	public Result<String> removeQueueDriver(String phone) throws Exception {
		this.tmsQueueService.removeDriver(phone);
		return new Result<>(true, null, "删除成功");
	}

}